package com.qf.j2205.controller;

import com.qf.j2205.entity.Dpt;

import java.sql.*;
import java.util.List;

/**
 * @ClassName DptServlet
 * @Description TODO
 * @Author 16222
 * @Date 2022/8/22 20:01
 * @Version 1.0
 **/
public class DptServlet {
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public List<Dpt> findALl() throws SQLException {
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/j2205", "root", "root123");
        String sql = "select * from dpt";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1));
            System.out.println(resultSet.getString(2));
            System.out.println(resultSet.getString(3));

        }

        return null;
    }
}
